<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- Vue 指令 v-on -->
    <!-- 作用: 注册事件 = 监听事件 + 提供逻辑处理 -->
    <!-- 语法: 1.v-on:事件名="内联语句" -->
    <div id="app">
      <button v-on:click="count--">-</button>
      <!-- 简写 v-on: => @-->
      <button @click="count--">-</button>
      <span>{{ count }}</span>
      <button v-on:click="count++">+</button>
    </div>

    <!-- 语法: 2.v-on:事件名="methods中的函数名" -->
    <div id="box">
      <button @click="ChangeValue">切换显示隐藏</button>
      <h1 v-show="isShow">HP</h1>
    </div>

    <script src="./vue.js"></script>
    <script>
      const app = new Vue({
        el: "#app",
        data: {
          count: 100,
        },
      });

      const box = new Vue({
        el: "#box",
        data: {
          isShow: false,
        },
        methods: {
            // methods 中的函数,this都指向当前实例(box)
          ChangeValue() {
            console.log(box === this) // true
            this.isShow = !this.isShow
          },
        },
      });
    </script>
  </body>
</html>
